package com.ehotting.edsta.system.api;

import com.ehotting.eaf.core.constant.SecurityConstants;
import com.ehotting.eaf.core.constant.ServiceNameConstants;
import com.ehotting.eaf.core.domain.R;
import com.ehotting.eaf.core.web.domain.AjaxResult;
import com.ehotting.eaf.core.domain.system.api.SysUser;
import com.ehotting.edsta.system.api.factory.RemoteUserFallbackFactory;
import com.ehotting.eaf.core.domain.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 用户服务
 * 
 * @author edsta
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户名查询用户信息
     *
     * @return 结果
     */
    @GetMapping("/user/getByUserId")
    AjaxResult getByUserId(Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @PostMapping("/user/userNameUnique")
    AjaxResult checkUserNameUnique(@RequestBody String username);

    @PostMapping("/user/phoneUnique")
    AjaxResult checkPhoneUnique(@RequestBody SysUser user);

    @GetMapping("/user/{userId}" )
    AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId);

    @PostMapping("/user/sms/register")
    AjaxResult smsRegister(@RequestBody SysUser user);

    @PutMapping("/user/resetPwd4Client")
    AjaxResult resetPwd4Client(@RequestBody SysUser user);
}
